home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / var / lib / dpkg / info / base-files.postinst < prev    next >
Encoding:
Text File  |  2012-09-23  |  3.0 KB  |  109 lines

  1. #!/bin/sh
  2. set -e
  3.  
  4. install_local_dir() {
  5.   if [ ! -d $1 ]; then
  6.     mkdir -p $1
  7.   fi
  8.   chown root:staff $1 2> /dev/null || true
  9.   chmod 2775 $1 2> /dev/null || true
  10. }
  11.  
  12. install_from_default() {
  13.   if [ ! -f $2 ]; then
  14.     cp -p $1 $2
  15.   fi
  16. }
  17.  
  18. install_directory() {
  19.   if [ ! -d /$1 ]; then
  20.     mkdir /$1
  21.     chown root:$3 /$1
  22.     chmod $2 /$1
  23.   fi
  24. }
  25.  
  26. if [ ! -e /etc/dpkg/origins/default ]; then
  27.   if [ -e /etc/dpkg/origins/debian ]; then
  28.     ln -sf debian /etc/dpkg/origins/default
  29.   fi
  30. fi
  31.  
  32. if [ "$1" = "configure" ] && [ "$2" = "" ]; then
  33.   install_from_default /usr/share/base-files/nsswitch.conf /etc/nsswitch.conf
  34.   install_from_default /usr/share/base-files/dot.profile   /root/.profile
  35.   install_from_default /usr/share/base-files/dot.bashrc    /root/.bashrc
  36.   install_from_default /usr/share/base-files/profile       /etc/profile
  37.   install_from_default /usr/share/base-files/motd          /etc/motd
  38.   install_directory srv       755 root
  39.   install_directory opt       755 root
  40.   install_directory etc/opt   755 root
  41.   install_directory var/opt   755 root
  42.   install_directory media     755 root
  43.   install_directory var/mail 2775 mail
  44.   if [ ! -L /var/spool/mail ]; then
  45.     ln -s ../mail /var/spool/mail
  46.   fi
  47.  
  48.   install_local_dir /usr/local
  49.   install_local_dir /usr/local/share
  50.   install_local_dir /usr/local/share/man
  51.   install_local_dir /usr/local/bin
  52.   install_local_dir /usr/local/games
  53.   install_local_dir /usr/local/lib
  54.   install_local_dir /usr/local/include
  55.   install_local_dir /usr/local/sbin
  56.   install_local_dir /usr/local/src
  57.   install_local_dir /usr/local/etc
  58.   ln -sf share/man /usr/local/man
  59.  
  60.   if [ ! -f /var/log/wtmp ]; then
  61.     echo -n>/var/log/wtmp
  62.   fi
  63.   if [ ! -f /var/log/btmp ]; then
  64.     echo -n>/var/log/btmp
  65.   fi
  66.   if [ ! -f /var/log/lastlog ]; then
  67.     echo -n>/var/log/lastlog
  68.   fi
  69.   chown root:utmp /var/log/wtmp /var/log/btmp /var/log/lastlog
  70.   chmod 664 /var/log/wtmp /var/log/lastlog
  71.   chmod 660 /var/log/btmp
  72.   if [ ! -f /var/run/utmp ]; then
  73.     echo -n>/var/run/utmp
  74.   fi
  75.   chown root:utmp /var/run/utmp
  76.   chmod 664 /var/run/utmp
  77. fi
  78.  
  79. if [ ! -d /var/lib/dpkg ]; then
  80.   mkdir -m 755 -p /var/lib/dpkg
  81.   chown root:root /var/lib/dpkg
  82. fi
  83. if [ ! -f /var/lib/dpkg/status ]; then
  84.   echo > /var/lib/dpkg/status
  85.   chmod 644 /var/lib/dpkg/status
  86.   chown root:root /var/lib/dpkg/status
  87. fi
  88.  
  89. if [ ! -f /usr/info/dir ] && [ ! -f /usr/share/info/dir ]; then
  90.   install_from_default /usr/share/base-files/info.dir /usr/share/info/dir
  91.   chmod 644 /usr/share/info/dir
  92.   chown root:root /usr/share/info/dir
  93. fi
  94.  
  95. if [ "$1" = "configure" ] && [ "$2" != "" ]; then
  96.   if [ -f /etc/motd ]; then
  97.     oldmd=`awk 'NR > 2' /etc/motd | md5sum | awk '{print $1}'`
  98.     newmd=`awk 'NR > 2' /usr/share/base-files/motd | md5sum | awk '{print $1}'`
  99.     if [ "$oldmd" != "$newmd" ]; then
  100.       if grep -q "$oldmd" /usr/share/base-files/motd.md5sums; then
  101.         awk 'NR <= 2' /etc/motd > /etc/motd.new
  102.         awk 'NR > 2' /usr/share/base-files/motd >> /etc/motd.new
  103.         mv /etc/motd /etc/motd.old
  104.         mv /etc/motd.new /etc/motd
  105.       fi
  106.     fi
  107.   fi
  108. fi
  109.